//
//  TransitionConfigForAnimation.swift
//  Swift-app开发基础架构
//
//  Created by pro on 2017/8/16.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

import UIKit

typealias AnimatedClouse = (UIViewControllerContextTransitioning) -> ()

// 动画的实际配置类
class KZAnimatedTransitioning: NSObject, UIViewControllerAnimatedTransitioning {
    
    var duration: Double?
    var animatedClouse: AnimatedClouse?
    
    init(duration: Double, animatedClouse: @escaping AnimatedClouse) {
        super.init()
        self.duration = duration
        self.animatedClouse = animatedClouse
    }
    
    // MARK: 实现 UIViewControllerAnimatedTransitioning 代理
    func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        
        return duration ?? 0.5
    }
    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        
        animatedClouse?(transitionContext)
    }
}
